package com.easylinkin.sm.entity;

import com.baomidou.mybatisplus.annotation.TableName;
import javax.persistence.AttributeOverride;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import lombok.Data;
import lombok.experimental.FieldNameConstants;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import site.morn.data.Displayable;
import site.morn.framework.entity.BaseDepartment;

/**
 * 组织结构实体类
 *
 * @author yhmaoc
 * @since 0.1.0, 2019/4/15
 */
@Data
@Entity
@DynamicInsert
@DynamicUpdate
@FieldNameConstants
@Table(name = "sm_department")
@TableName("sm_department")
@AttributeOverride(name = "id", column = @Column(name = "id_"))
@AttributeOverride(name = "parentId", column = @Column(name = "parent_id_"))
@AttributeOverride(name = "name", column = @Column(name = "name_", length = 32))
@AttributeOverride(name = "code", column = @Column(name = "code_", length = 32))
@AttributeOverride(name = "email", column = @Column(name = "email_", length = 32))
@AttributeOverride(name = "contact", column = @Column(name = "contact_"))
@AttributeOverride(name = "address", column = @Column(name = "address_"))
@AttributeOverride(name = "level", column = @Column(name = "level_"))
@AttributeOverride(name = "searchCode", column = @Column(name = "search_code_"))
@AttributeOverride(name = "remark", column = @Column(name = "remark_", length = 128))
@AttributeOverride(name = "modifier", column = @Column(name = "modifier_", length = 32))
@AttributeOverride(name = "modifyTime", column = @Column(name = "modify_time_"))
@AttributeOverride(name = "creator", column = @Column(name = "creator_", length = 32))
@AttributeOverride(name = "createTime", column = @Column(name = "create_time_"))
public class Department extends BaseDepartment implements Displayable {

  /**
   * @serialField
   */
  private static final long serialVersionUID = 1L;

  /**
   * 父类id
   */
  @Min(Long.MIN_VALUE)
  @Max(Long.MAX_VALUE)
  @Column(name = "parent_id_")
  private Long parentId;

  /**
   * 父类名称
   */
  @Transient
  private String parentName;

  /**
   * 所属客户
   */
  @Min(Long.MIN_VALUE)
  @Max(Long.MAX_VALUE)
  @Column(name = "customer_id_")
  private Long customerId;

  /**
   * 所属客户
   */
  @Transient
  private String customerName;

  /**
   * 排序
   */
  @Min(Integer.MIN_VALUE)
  @Max(Integer.MAX_VALUE)
  @Column(name = "order_no_")
  private Integer orderNo;

  /**
   * 显示状态
   */
  @Column(name = "display_")
  private Boolean display;

}
